import java.util.Arrays;
import java.util.Scanner;

public class Text4 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] arr1 = new int[n];
        int[] arr2 = new int[n];

        for (int i = 0; i < n; i++) {
            arr1[i] = sc.nextInt();
        }
        for (int i = 0; i < n; i++) {
            arr2[i] = sc.nextInt();
        }

        Arrays.sort(arr1);
        int tmp = 0; // 缺的卡牌总数
        int ret = arr1[n-1];
        for (int i = 0; i < n; i++){
            tmp += arr1[n-1] - arr1[i] ;
        }

        while(tmp >= m){
            tmp -= n - 1;
            ret --;
        }

        for (int i = 0; i < n; i++) {
            if (arr1[i] + arr2[i] < ret){
               while(arr1[i] + arr2[i] >= ret){
                   ret --;
               }
            }
        }

        System.out.println(ret);
    }
}
